<template>
	<!-- 员工详情 -->
  <div class="stu">
	 <el-dialog v-loading="loading"  :title="num==1?'编辑医疗保障信息':'新增医疗保障信息'" :visible.sync="dialogVisible" width="35%" :before-close="handleClose" :close-on-click-modal='false'>
	   <!-- <p class="pbox" style="text-align: center;width:100%;font-size:30px;height:40px;">员工信息详情</p> -->
	    <div style="width:100%;padding-bottom:20px;">
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>家庭</p>
					<el-select style="width:75%;border:none;" class="pboxc1" v-model="activess.family_id" clearable filterable placeholder="请选择">
					  <el-option v-for='item in $store.state.jia_ting' :key='item.family_id' :label="item.pop_name" :value="item.family_id"></el-option>
					</el-select>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>人员姓名</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.user_name" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>医院</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.hospital" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>身份证号</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.card" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>个人支付</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.persoan_pay_fee" clearable>
						<template slot="append">￥</template>
					</el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>报销比列</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.bx_bl" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>总费用</p>
					<el-input style='width:75%;' type='number' min='0' placeholder="请输入" v-model="activess.all_pay_fee" clearable>
						<template slot="append">￥</template>
					</el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>报销时间</p>
					<el-date-picker  style='width:75%;' v-model="activess.current_date" type="date" value-format='yyyy-MM-dd' placeholder="选择日期"></el-date-picker>
			</div>
		</div>	
		<div style="width:100%;height:40px;margin-top:20px;">
	      <div style="width:170px;margin: 0 auto;">
	        <el-button type="danger" @click="handleClose">取 消</el-button>
	        <el-button type="primary" style='float:right;' @click="git_acts">确 定</el-button>
	      </div>
		</div>
	 </el-dialog>
	
  </div>
</template>

<script>
import $ from 'jquery'
export default {
  name: 'stu',
  components: {},//声明子组件
  computed:{
	  
  },
  data(){
	  return {
		loading:false,
		btn_shou:false,
		dialogVisible: false,
		activess:{
			 user_name:'',//人员
			 card:'',//证件号码
			 family_id:'',//家庭ID
			 medical_type:'12',//医疗类型
			 hospital:'',//医院
			 all_pay_fee:'',//总费用
			 persoan_pay_fee:'',//个人自付
			 bx_bl:'',//报销比列
			 current_date:'',//年度展示   报销时间
			 id:'',//主键,
		},
		
		renbox:[],
		num:0,
	  }
  },
  methods:{
	  git_act(i,num){//获取数据的同打开狂口
	      if(num==1){
			  this.activess = i;
			  // this.activess.is_out = this.activess.is_out+'';
		  }
		  this.num = num;
	      console.log(this.activess,num);
	      this.dialogVisible=true;
	  },
	  git_acts(){//提交数据
	        console.log(this.activess);
	        if(this.isNull(this.activess.family_id)){this.$message.error('请选择 家庭');return false}
	  		if(this.isNull(this.activess.user_name)){this.$message.error('请输入 人员姓名');return false}
			if(this.isNull(this.activess.hospital)){this.$message.error('请输入 医院名称');return false}
			if(this.isNull(this.activess.card)){this.$message.error('请输入 身份证号');return false}
			if(this.iscard(this.activess.card)){this.$message.error('身份证号格式不正确');return false}
			if(this.isNull(this.activess.persoan_pay_fee)){this.$message.error('请输入 个人支付金额');return false}
			if(this.isNull(this.activess.bx_bl)){this.$message.error('请输入 报销比列');return false}
			if(this.isNull(this.activess.all_pay_fee)){this.$message.error('请输入 总费用');return false}
			if(this.isNull(this.activess.current_date)){this.$message.error('请输入 报销时间');return false}
			
	  		 let url = this.num==1?'/dj/user_pc/medical_modify':'/dj/user_pc/medical_add';
	  		 $.ajax({url:url,type:'post',data:this.activess,dataType:'json',success:(res)=> {
	  		 	if(Object.prototype.toString.call(res) != '[object Object]'){res = JSON.parse(res)}
	  		 	 console.log(res,'提交');
	  		 	 if(res.code==200){
	  				this.$parent.git_act();
	  		 		this.$message({message: '操作成功',type: 'success'});
	  		 		this.dialogVisible=false;
	  				this.qin();
	  		 	  }else{
	  		 		 this.$message.error(res.msg);
	  		 	  }
	  		 	}
	  		 })
	  },
	  qin(){//清除
	  	this.activess={
			 user_name:'',//人员
			 card:'',//证件号码
			 family_id:'',//家庭ID
			 medical_type:'12',//医疗类型
			 hospital:'',//医院
			 all_pay_fee:'',//总费用
			 persoan_pay_fee:'',//个人自付
			 bx_bl:'',//报销比列
			 current_date:'',//年度展示   报销时间
			 id:'',//主键,
		}
	  },
	  
	  handleClose(done){//监测用户点击x
	     this.$confirm('确定取消关闭吗？','提示',{confirmButtonText:'确定',cancelButtonText:'取消',type: 'warning'}).then(() => {
	  	   this.dialogVisible = false;
	  	   this.qin();
		   this.$parent.git_act();
	  	}).catch(() => {});
	  },
	  
  },
  mounted(){
	  // this.git_ren()
  }
}
</script>
<style scoped="scoped">
	
	.pboxc1{
		float:left;
		width:70%;
		height:40px;
		border:1px solid rgba(242,242,242,1);
		font-size:14px;color:#666666;
		/* padding-left:18px; */
		text-align:left;
		/* overflow: hidden; */
		/* text-overflow:ellipsis; */
		/* white-space: nowrap; */
	}
	.tabbox{
		width:100%;
		height:40px;
		line-height: 30px;
		margin-top:23px;
	}
	.tabbox p{
		font-size:14px;
		color:#000000;
		width:19.5%;
		text-align:right;
		margin-right:28px;
		float:left;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		font-family:Source Han Sans CN;
	}
	.pbox{
		width:10%;
		text-align:right;
		height:26px;
		margin-bottom:20px;
		font-size:18px;
		color:#000101;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		font-family:Source Han Sans CN;
		font-weight:600;
	}
</style>
